package com.djl.zenithbite.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class RedisKeyUtil {
    private static final String SPLIT = ":";
    private static final String CODE_KEY = "code";
    private static final String TICKET_KEY = "ticket";
    private static final String USER_KEY = "user";
    private static final String UV_KEY = "uv";
    private static final String DAU_KEY = "dau";
    private static final String SEAT_KEY = "seat";
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm");


    public static String getCodeKey(String ticket) {
        return CODE_KEY + SPLIT + ticket;
    }

    public static String getTicketKey(String ticket) {
        return TICKET_KEY + SPLIT + ticket;
    }

    public static String getUserKey(int userId) {
        return USER_KEY + SPLIT + userId;
    }

    public static String getUvKey(String date) {
        return UV_KEY + SPLIT + date;
    }

    public static String getUvKey(String start, String end) {
        return UV_KEY + SPLIT + start + SPLIT + end;
    }

    public static String getDauKey(String date) {
        return DAU_KEY + SPLIT + date;
    }

    public static String getDauKey(String start, String end) {
        return DAU_KEY + SPLIT + start + SPLIT + end;
    }

    public static String getSeatKey(String trainId, Date startTime, Date endTime) {
        return SEAT_KEY + SPLIT + trainId + SPLIT + sdf.format(startTime) + SPLIT + sdf.format(endTime);
    }
}
